<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>事件修饰符</title>
    <style>
      .parent-div {
        position: relative;
        width: 100px;
        height: 100px;
        border: 1px solid pink;
      }
      .child-div {
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        width: 50px;
        height: 50px;
        border: 1px solid red;
      }
    </style>
    <script src="../lib/vue_v2.6.14.js"></script>
  </head>
  <body>
    <div id="app">
      <!-- 1、阻止事件冒泡 -->
      <div class="parent-div" @click="parentClick">
        <div class="child-div" @click.stop="childClick"></div>
      </div>

      <!-- 2、阻止事件默认行为 -->
      <p>
        <a href="https://baidu.com" @click.parent="aClick">百度</a>
      </p>

      <!-- 3、按键修饰符 -->
      <p>
        <input type="text" value="" @keyup.enter="keyUp" />
      </p>
    </div>

    <script>
      const vm = new Vue({
        el: '#app',
        data: {
          message: '你好'
        },
        methods: {
          childClick() {
            console.log('childClick')
          },
          parentClick() {
            console.log('parentClick')
          },
          aClick() {
            console.log('aClick')
          },

          // 按键
          keyUp(e) {
            console.log('你输入----', e.target.value)
          }
        }
      })
    </script>
  </body>
</html>
